{% extends 'base.html' %}
{% block content %}
    <div class="container">
        <div class="page-header">
            <h1></h1>
        </div>
        <form class="form-inline" action="{% url 'grade' %}" method="POST">
            <div class="row" style="margin: 10px; width: 90%">
                <div class="form-group col col-sm-2">
                    <label class="sr-only" for="exampleInputYear">年份</label>
                    <label>
                        <select class="form-control" name="inputYear">
                            <option value="2018">2018-2019</option>
                            <option value="2019">2019-2020</option>
                            <option value="2020" selected="selected">2020-2021</option>
                        </select>
                    </label>
                </div>
                <div class="form-group col col-sm-1">
                    <label class="sr-only" for="exampleInputSemester">学期</label>
                    <label>
                        <select class="form-control" name="inputSemester">
                            <option value="">全部</option>
                            <option value="3">上学期</option>
                            <option value="12">下学期</option>
                        </select>
                    </label>
                </div>
                <input type="hidden" id="username" name="username" value="{{ username }}">
                <input type="hidden" id="password" name="password" value="{{ password }}">
                <input type="hidden" id="numid" name="numid" value="{{ numid }}">
                <button type="submit" class="btn btn-success col col-sm-1 " style="margin-left: 50px">查询</button>
            </div>
        </form>
    </div>
    <div class="container">
        <table class="table table-hover table-dark">
            <thead>
            <tr>
                <th scope="col">#</th>
                <th scope="col">课程号</th>
                <th scope="col">课程名称</th>
                <th scope="col">绩点</th>
                <th scope="col">课程类别</th>
                <th scope="col">学分</th>
                <th scope="col">学分绩点</th>
                <th scope="col">成绩</th>
            </tr>
            </thead>
            <tbody>
            {% for x in api.items %}
                <tr>
                    <th scope="row">{{ forloop.counter }}</th>
                    <td>{{ x.kch }}</td>
                    <td>{{ x.kcmc }}</td>
                    <td>{{ x.jd }}</td>
                    <td>{{ x.kcxzmc }}</td>
                    <td>{{ x.xf }}</td>
                    <td>{{ x.xfjd }}</td>
                    <td>{{ x.cj }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <div class="alert alert-success" role="alert"><strong>学位课程加权平均分</strong> = ∑(学分 * 成绩) / ∑ 学分</div>
    </div>
{% endblock %}